﻿using System;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.ServiceModel.Activation;
using System.Collections.Generic;
using System.Text;
using BLL.Clustering;
using DO.Clustering;

namespace SVC.Clustering
{
    
    [AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]
    public class ClusteringService:IClusteringService
    {
        #region Implementation of IClusteringService

        public DocumentClusteringOutput ClusterDocs(Guid ticket, DocumentClusteringInstruction instruction)
        {
            ClusteringWorker worker = new ClusteringWorker();
            worker.SetInstruction(ticket, instruction.Serialize().ToString(), "Clustering", "Clustering");
            worker.DoWork();
            return worker.Output as DocumentClusteringOutput;
        }

        public List<string> GetClusteringResultNames(string connName, string resultTbl, string taskField)
        {
            return ClusteringResultManager.GetClusteringResultNames(connName, resultTbl, taskField);
        }

        public DocumentClusteringOutput GetClusteringOutput(string connName, string resultTbl, string taskField, string dataField, string taskName)
        {
            return ClusteringResultManager.GetClusteringOutput(connName, resultTbl, taskField, dataField, taskName);
        }

        public void DeleteClusteringResult(string connStr, string resultTbl, string taskField, string dataField, string taskName)
        {
            ClusteringResultManager.DeleteClusteringResult(connStr, resultTbl, taskField, dataField, taskName);
        }

        public void RenameClusteringResult(string connStr, string resultTable, string taskField, string oldName, string newName)
        {
            ClusteringResultManager.RenameClusteringResult(connStr,resultTable,taskField,oldName,newName);
        }

        #endregion
    }
}
